package com.example.demo.controller;

import java.util.List;

import com.example.demo.entity.User;
import com.example.demo.service.impl.UserServiceImpl;
import com.example.demo.utils.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController()
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("index")
    public Result index() {

        List<User> userList= userService.getUserList();
        return Result.success(userList);
        
    }

    @RequestMapping("add")
    public Result add(@RequestBody User user) {
        Long time = System.currentTimeMillis() / 1000;
        user.setCreateTime(time);
        user.setUpdateTime(time);
        boolean flag = userService.addUser(user);
        return Result.success();
    }

}
